
from .wrapper import equal_length


@equal_length
def multi_labels_measure(gt: list[list], 
                         sample: list[list]) -> tuple[float, float]:
    tp, acc, recall = 0, 0, 0
    
    for g, s in zip(gt, sample):
        tp += sum([1 for a in g if a in s])
        acc += len(s)
        recall += len(g)
    
    acc = tp / acc if acc else -2
    recall = tp / recall if recall else -2
    # print(f'acc: {acc} | recall: {recall}')
    return acc, recall
        
@equal_length
def acc(gt: list, sample: list) -> float:
    TP, all = sum(1 for a, b in zip(gt, sample) if a == b), len(gt)
    return TP / all